package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import model.newUser;

public class UserDaoA {
	public static ResultSet list(Connection con,newUser type) throws Exception{
		StringBuffer sb=new StringBuffer("select * from cust ");
		if(type.setcustId()!=null) {
			sb.append(" and custId like '%"+type.setcustId()+"%' ");
		}else if(type.setcustLogin()!=null) {
			sb.append(" and custLogin like '%"+type.setcustLogin()+"%''");
		}else if(type.setcustPwd()!=null) {
			sb.append(" and custPwd like '%"+type.setcustPwd()+"%' ");
		}else if(type.setcustSex()!=null) {
			sb.append(" and custSex like '%"+type.setcustSex()+"%' ");
		}else if(type.setcustAge()!=null) {
			sb.append(" and custAge like '%"+type.setcustAge()+"%' ");
		}else if(type.setcustName()!=null) {
			sb.append(" and custName like '%"+type.setcustName()+"%'");
		}else if(type.setcustTel()!=null) {
			sb.append(" and custTel like '%"+type.setcustTel()+"%' ");
		}else if(type.setcustNum()!=null) {
			sb.append(" and custNum like '%"+type.setcustNum()+"%' ");
		}
		
		PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and","where"));
		return pstmt.executeQuery();
	}
}
